package com.cwm.test.proxy.jdkreflect;

import com.cwm.test.proxy.staticproxy.OldClass;
import com.cwm.test.proxy.staticproxy.Source;
import sun.misc.ProxyGenerator;

import java.io.FileOutputStream;

public class Main {
    public static void main(String[] args) {
        Source calculator = new OldClass();
        ProxyInvocationHandler handler = new ProxyInvocationHandler();
        Source proxy = (Source)handler.getInstance(calculator);
        proxy.add(1, 2);
        byte[] bytes = ProxyGenerator.generateProxyClass("$Proxy0.class",new Class[]{Source.class});

        try{
            FileOutputStream os = new FileOutputStream("C://$Proxy0.class");
            os.write(bytes);

        }catch (Exception e){


        }

    }
}